home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 726-750 / 742 / icalc / s / icalc.init next >
Text File  |  1995-03-18  |  2KB  |  65 lines

  1. # Standard startup-file for icalc.
  2. # Updated for version 2.1. Also, you may want to include other scripts
  3. # (such as gamma.ic) by read command.
  4. #
  5. # MWS, July 1992.
  6.  
  7. silent        # switch off confirmation of definitions
  8.  
  9. # function informing you how long icalc session has been running in seconds.
  10. _sessionstart = time(0)
  11. 0 # restore ans to zero
  12. func session() = time(_sessionstart)
  13.  
  14. # simple stopwatch functions
  15. func start() = (_start = time(0))
  16. func stop() = time(_start)
  17.  
  18. # timer of evaluation
  19. func timer(~expr) = { local t; t = time(0); print(expr); time(t); }
  20.  
  21. # a few simple time-savers
  22. func deg(z) = DEG*z        # convert radians to degrees
  23. func rad(z) = z/DEG        # and degrees to radians
  24. func log(z) = ln(z)/LOG10    # base-10 logarithm
  25. func lg(z) = ln(z)/LOG2        # base-2 logarithm
  26. func logn(z,n) = ln(z)/ln(n)    # base-n logarithm (works with complex bases too:)
  27.  
  28. # switch bases - note adjustment of significant figures
  29. func bin() = { outbase(2); prec(35); }        # display results in binary
  30. func oct() = { outbase(8); prec(15); }        # display results in ocal
  31. func dec() = { outbase(10); prec(12); }        # display results in decimal
  32. func hex() = { outbase(16); prec(10); }        # display results in hexadecimal
  33.  
  34. # inverse hyperbolic trig functions
  35. func asinh(z) = -i*asin(i*z)
  36. func acosh(z) = -i*acos(z)
  37. func atanh(z) = i*atan(-i*z)
  38.  
  39. # combinatorics - could be replaced with defs in gamma.ic
  40. func fact(n) = Prod(_n=1,n,_n)
  41. func perm(n,r) = Prod(_n=n-r+1,n,_n)
  42. func comb(n,r) = perm(n,r)/fact(r)
  43.  
  44. # miscellaneous
  45.  
  46. # fractional part of a number
  47. func frac(z) = Re(z - floor(z))
  48.  
  49. # round real & imag parts
  50. func round(z,places) = int(z*10^places)/10^places
  51.  
  52. # create complex number from modulus and argument
  53. func polar(r,theta) = r*exp(i*theta)
  54.  
  55. # create complex number from real and imaginary parts
  56. func complex(real,imag) = real + i*imag
  57.  
  58. # convert decimal hours to hours, mins, seconds
  59. func hms(h) = { print(floor(h)); print(floor(_t = frac(h)*60)); frac(_t)*60; }
  60.  
  61. # convert hours, mins, seconds to decimal hours
  62. func hours(h,m,s) = h+m/60+s/3600
  63.  
  64. verbose        # restore display of results, messages
  65.